package com.zzzs.single;

import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.TimeUnit;

/**
 * @author zhu_shuai
 * @since 7/28
 */
public class Test {
    public static void main(String[] args) throws InterruptedException, BrokenBarrierException {
        // CountDownLatch countDownLatch = new CountDownLatch(1);
        CyclicBarrier cyclicBarrier = new CyclicBarrier(100);
        for (int i = 0; i < 99; i++) {
            new Thread(() -> {
                // System.out.println(Thread.currentThread());
                try {
                    // countDownLatch.await();
                    cyclicBarrier.await();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                } catch (BrokenBarrierException e) {
                    e.printStackTrace();
                }
                System.out.println(LazyMan.getInstance());
            }).start();
        }
        TimeUnit.SECONDS.sleep(3);
        cyclicBarrier.await();
        System.out.println("end");
    }
}
